home *** CD-ROM | disk | FTP | other *** search
/ PCMania 75 / PCMania CD75_1.iso / pcmania / sbits75 / vowel.saol < prev    next >
Text File  |  1998-11-29  |  1KB  |  71 lines

  1.  
  2. global {
  3.   srate 16000;
  4.   krate 400;
  5.   outchannels 1;
  6. }
  7.  
  8. instr voice1(startmidi,startvwl,startamp) {
  9.   asig vibfreq,a,reson1,reson2,out;
  10.   ksig kinit,f1,f2,curf1,curf2,ct,oldf1,oldf2;
  11.   imports ksig vowel,amp,pitch,stop;
  12.   table vib(harm,128,1);
  13.   ivar trans;
  14.  
  15.   trans = 0.1;
  16.  
  17.   if (!kinit) {
  18.     kinit = 1;
  19.     vowel = startvwl;
  20.     amp = startamp;
  21.     pitch = startmidi;
  22.   }
  23.  
  24.   if (stop) { turnoff; }
  25.   // kdump(pitch);
  26.   vibfreq = cpsmidi(pitch) * (oscil(vib,5,-1)*0.02 + 1)/2 + arand(5);  
  27.   a = buzz(vibfreq,0,1,0.8) * amp;
  28.  
  29.   if (vowel == 1) { // /i/
  30.     f1 = 260;
  31.     f2 = 2200;
  32.   }
  33.   if (vowel == 2) { // /u/
  34.     f1 = 310;
  35.     f2 = 900;
  36.   }
  37.   if (vowel == 3) { // /a/
  38.     f1 = 750;
  39.     f2 = 1100;
  40.   }
  41.   if (vowel == 4) { // /E/ 
  42.     f1 = 550;
  43.     f2 = 1750;
  44.   }
  45.  
  46.   if (!oldf1) {
  47.     oldf1 = f1; curf1 = f1;
  48.     oldf2 = f2; curf2 = f2;
  49.   }
  50.  
  51.   if (f1 != oldf1 || f2 != oldf2) {
  52.     curf1 = oldf1 + ct/trans * (f1-oldf1);
  53.     curf2 = oldf2 + ct/trans * (f2-oldf2);
  54.     ct = ct + 1/k_rate;
  55.   }
  56.  
  57.   if (ct > trans) {
  58.     ct = 0;
  59.     oldf1 = f1;
  60.     oldf2 = f2;
  61.   }
  62.       
  63.   reson1 = bandpass(a,curf1,curf1/5.5);
  64.   reson2 = bandpass(a,curf2,curf2/5.5);
  65.  
  66.   out = (a/4 + reson1 + reson2)/2;
  67.   
  68.   output(out);
  69. }
  70.  
  71.